package cn.btks.resultintegration.rule.controller;

import cn.btks.commonserver.result.ResultState;
import cn.btks.commonserver.result.StateInfo;
import cn.btks.resultintegration.rule.pojo.EIACategory;
import cn.btks.resultintegration.rule.pojo.IndustrialPark;
import cn.btks.resultintegration.rule.service.IndustrialParkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author lijun
 * @Date 2021/2/19 11:04
 */
@RestController
@RequestMapping("api/v1.0/resultIntegration/rule")
@Api(tags = "规则模块")
@Validated
public class IndustrialParkController {

    @Autowired
    IndustrialParkService industrialParkService;

    @GetMapping("/industrialPark/findAllIndustrialPark")
    @ApiOperation("查询所有工业园区规划")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "token密匙", required = true, dataType = "string")
    })
    public ResultState findAllIndustrialPark() {
        List<IndustrialPark> industrialParkList = industrialParkService.findAllIndustrialPark();
        return industrialParkList != null ? new ResultState(StateInfo.FIND_OK.getCode(),
                StateInfo.FIND_OK.getMsg(), industrialParkList) : new ResultState(StateInfo.FIND_NULL.getCode(),
                StateInfo.FIND_NULL.getMsg());
    }

    @GetMapping("/industrialPark/findAllByIndustryCode/{industryCode}")
    @ApiOperation("根据产业结构ID查询工业园区信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "industryCode", value = "产业结构ID", required = true, dataType = "long"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "token密匙", required = true, dataType = "string")
    })
    public ResultState findAllByIndustryCode(@PathVariable("industryCode") Long industryCode) {
        List<IndustrialPark> industrialParkList = industrialParkService.findAllByIndustryCode(industryCode);
        return industrialParkList != null ? new ResultState(StateInfo.FIND_OK.getCode(),
                StateInfo.FIND_OK.getMsg(), industrialParkList) : new ResultState(StateInfo.FIND_NULL.getCode(),
                StateInfo.FIND_NULL.getMsg());
    }

    @GetMapping("/industrialPark/findAllIndustryByGkdybh/{ysgkdybm}")
    @ApiOperation("根据管控要素编码查询产业名称")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "ysgkdybm", value = "要素管控单元编码", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "token密匙", required = true, dataType = "string")
    })
    public ResultState findAllIndustryByGkdybh(@PathVariable("ysgkdybm") String ysgkdybm) {
        List<Map<String, Object>> mapList = industrialParkService.findAllIndustryByGkdybh(ysgkdybm);
        return mapList != null ? new ResultState(StateInfo.FIND_OK.getCode(),
                StateInfo.FIND_OK.getMsg(), mapList) : new ResultState(StateInfo.FIND_NULL.getCode(),
                StateInfo.FIND_NULL.getMsg());
    }
}
